package ice.dao.util;

import ice.Constants;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;

import org.logicalcobwebs.proxool.ProxoolException;
import org.logicalcobwebs.proxool.configuration.JAXPConfigurator;

/**
 * ProxoolPool
 * 
 * @author abiao
 */
public class ProxoolPool {

    /**
     * 初始化连接池配置
     */
    static {
        try {
            JAXPConfigurator.configure(Constants.PROXOOLFILE, false);
        } catch (ProxoolException e) {
            e.printStackTrace();
        }
    }

    /**
     * hide me
     */
    private ProxoolPool() {
    }

    /**
     * 获取新的数据库连接
     */
    public static Connection getConnection() throws Exception {
        Driver driver = (Driver) Class.forName(Constants.PROXOOL_DRIVER_NAME).newInstance();
        DriverManager.registerDriver(driver);
        return DriverManager.getConnection(Constants.DBPOOLKEY);
    }
}
